package HashTable;

import java.util.Hashtable;
import java.util.concurrent.CountDownLatch;

/**
 * @author wang'ji'cheng
 * @date 2025/7/28
 */
public class HashTableDemp {
    public static void main(String[] args) {
        Hashtable<String, Integer> hashtable = new Hashtable<>();
        CountDownLatch countDownLatch = new CountDownLatch(2);

        new Thread(()->{
            for (int i = 0; i < 25; i++) {
                hashtable.put(String.valueOf(i),i);
            }
            countDownLatch.countDown();
        }).start();

        new Thread(()->{
            for (int i = 25; i < 51; i++) {
                hashtable.put(String.valueOf(i),i);
            }
            countDownLatch.countDown();
        }).start();

        try {
            countDownLatch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(hashtable);

    }
}
